// Copyright (C) 2012 by Johann Duscher <jonny.dee@gmx.net>
//
// This file is part of barcodeart-pp.
//
// barcodeart-pp is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// barcodeart-pp is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with barcodeart-pp. If not, see <http://www.gnu.org/licenses/>.

#include "SizeDecorator.hpp"

namespace barcodeart
{

SizeDecorator::SizeDecorator(const IBarCode& delegate, int stretch)
    : m_pDelegate(&delegate), m_horizontalStretch(stretch), m_verticalStretch(stretch)
{
}

SizeDecorator::SizeDecorator(const IBarCode& delegate, int horizontalStretch, int verticalStretch)
    : m_pDelegate(&delegate), m_horizontalStretch(horizontalStretch), m_verticalStretch(verticalStretch)
{
}

SizeDecorator::~SizeDecorator()
{
}

void SizeDecorator::setHorizontalStretch(int value)
{
    m_horizontalStretch = value;
}

int SizeDecorator::getHorizontalStretch() const
{
    return m_horizontalStretch;
}

void SizeDecorator::setVerticalStretch(int value)
{
    m_verticalStretch = value;
}

int SizeDecorator::getVerticalStretch() const
{
    return m_verticalStretch;
}

int SizeDecorator::getWidth() const
{
    return m_pDelegate->getWidth() * m_horizontalStretch;
}

int SizeDecorator::getHeight() const
{
    return m_pDelegate->getHeight() * m_verticalStretch;
}

bool SizeDecorator::isBlack(int y, int x) const
{
    return m_pDelegate->isBlack(y / m_verticalStretch, x / m_horizontalStretch);
}

}
